# automatically generate formula based on a name list
# 
# Author: Guochun Shen
# Data:   2011-12-18
# Project:spatial statistic
# Email:  shenguochun@gmail.com
###############################################################################


auto_formu=function(name,del=NULL){
	l=length(name)
	if(l==0)
		return(as.formula("~1"))
	
	for (i in 1:l){
		if (i==1) fu=paste("~",name[i])
		else fu=paste(fu,"+",name[i])
	}
	if (!is.null(del))
		fu=paste(fu,del)
	
	fu=as.formula(fu)
	return(fu)
}
